﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace EntityComponentSystem.Framework
{
    public class TagList : IEnumerable<string>
    {
        private List<string> tags = new List<string>();
        private int entity = 0;

        public int Count { get { return tags.Count; } }

        public TagList(int entity)
        {
            this.entity = entity;
        }

        public void Add(GameEngine ge, string tag)
        {
            tags.Add(tag);
        }

        public void Remove(GameEngine ge, string tag)
        {
            for (int i = this.Count - 1; i >= 0; i--)
                if (tags[i] == tag)
                    tags.RemoveAt(i);
        }

        public void Clear(GameEngine ge)
        {
            for (int i = this.Count - 1; i >= 0; i--)
                ge.RemoveTag(entity, tags[i]);
        }

        public IEnumerator<string> GetEnumerator()
        {
            foreach (var tag in tags)
                yield return tag;
        }

        System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
        {
            foreach (var tag in tags)
                yield return tag;
        }
    }
}
